package com.chaoshi.strategy.impl;


import com.chaoshi.common.FruitPrices;
import com.chaoshi.strategy.PriceStrategy;

import java.math.BigDecimal;
import java.math.RoundingMode;


public class OriginalPriceStrategy implements PriceStrategy {
    private final FruitPrices prices;


    public OriginalPriceStrategy(FruitPrices prices) {
        this.prices = prices;
    }

    @Override
    public BigDecimal calculate(int a, int s, int m) {
        BigDecimal appleTotal = prices.getApple().multiply(new BigDecimal(a));
        BigDecimal strawberryTotal = prices.getStrawberry().multiply(new BigDecimal(s));
        return appleTotal.add(strawberryTotal)
                .setScale(2, RoundingMode.HALF_UP);
    }
}